package pl.org.lutra.planner.gui.table;

import java.util.List;

import pl.org.lutra.planner.gui.resources.Text;
import pl.org.lutra.planner.model.data.RuntimeSegment;

public class RuntimeTableModel extends PlannerTableModel<RuntimeSegment> {
    private static final long serialVersionUID = -8707901448217365984L;
    
    @Override
    protected PlannerColumn<RuntimeSegment>[] createColumns() {
        return new RuntimeColumn[] {RuntimeColumn.DEPTH, RuntimeColumn.RUNTIME};
    }
    
    @Override
    public void setSegments(List<RuntimeSegment> segments) {
        super.setSegments(segments);
        fireTableDataChanged();
    }
    
    enum RuntimeColumn implements PlannerColumn<RuntimeSegment> {
        DEPTH("column.depth") {
            @Override
            public Object getValue(RuntimeSegment segment) {
                return segment.getDepth();
            }
        },
        RUNTIME("column.runtime") {
            @Override
            public Object getValue(RuntimeSegment segment) {
                return segment.getRuntime();
            }
        };
        
        private String key;
        
        private RuntimeColumn(String key) {
            this.key = key;
        }
        
        @Override
        public String getLabel() {
            return Text.get(key);
        }
    }
}
